package cn.yanxiaohui.service.web.pattern.proxy.jdk.myself.impl;

import cn.yanxiaohui.service.web.pattern.proxy.jdk.myself.MyInvocationHandler;

import java.lang.reflect.Method;

/**
 * @Description 手写jdk动态代理
 * @Author： yanxh<br>
 * @Date 2019/12/9 17:31<br>
 * @Version 1.0<br>
 */
public class MyInvocationHandlerImpl implements MyInvocationHandler {

    private Object target;

    public MyInvocationHandlerImpl(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable{
        System.out.println("手写jdk动态代理。。。");
        Object invoke = method.invoke(target, args);
        System.out.println("手写jdk动态代理马哥笑了。。。");
        return invoke;
    }
}
